﻿using MockPrjTeam1.Biz;
using MockPrjTeam1.Entity;
using SD.Commons.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MockPrjTeam1.Pages.Views
{
    public partial class RegionList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var biz = new RegionBiz();
                var results = biz.GetActive();
                grvRegion.DataSource = results;
                grvRegion.DataBind();
            }
        }

        protected void GetAll(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.GetAll();
            else
                results = biz.GetActive();
            
            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void PageChanging(object sender, GridViewPageEventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;
            
            if (cbInActive.Checked)
                results = biz.GetAll();
            else
                results = biz.GetActive();

            grvRegion.PageIndex = e.NewPageIndex;
            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void Filter09(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.Filter(2, 0);
            else
                results = biz.Filter(2, 1);

            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void FilterAE(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.Filter(3, 0);
            else
                results = biz.Filter(3, 1);

            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void FilterFJ(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.Filter(4, 0);
            else
                results = biz.Filter(4, 1);

            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void FilterKN(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.Filter(5, 0);
            else
                results = biz.Filter(5, 1);

            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void FilterOR(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.Filter(6, 0);
            else
                results = biz.Filter(6, 1);

            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void FilterSV(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.Filter(7, 0);
            else
                results = biz.Filter(7, 1);

            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }

        protected void FilterWZ(object sender, EventArgs e)
        {
            var biz = new RegionBiz();
            List<Region> results = null;

            if (cbInActive.Checked)
                results = biz.Filter(8, 0);
            else
                results = biz.Filter(8, 1);

            grvRegion.DataSource = results;
            grvRegion.DataBind();
        }
    }
}